//
//  MineWeightDatePickerView.m
//  Shine
//
//  Created by dllo on 16/3/11.
//  Copyright © 2016年 王斌. All rights reserved.
//

#import "MineWeightDatePickerView.h"
#define WIDTHVIEW self.frame.size.width
#define HEIGHTVIEW self.frame.size.height
#define BGSVFSW self.backGroundSmallView.frame.size.width
#define BGSVFSH self.backGroundSmallView.frame.size.height
@implementation MineWeightDatePickerView

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self createView];
    }
    return self;
}

- (void)createView{

    self.backGroundSmallView = [[UIView alloc] init];
    [self addSubview:self.backGroundSmallView];
    self.titleLabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.titleLabel];
    self.textFieldNumber = [[UITextField alloc] init];
    [self.backGroundSmallView addSubview:self.textFieldNumber];
    self.kgLabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.kgLabel];
    self.dateLabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.dateLabel];
    self.saveButton = [[UIButton alloc] init];
    [self.backGroundSmallView addSubview:self.saveButton];
    self.xButton = [[UIButton alloc] init];
    [self.backGroundSmallView addSubview:self.xButton];
    self.dateClickLabel = [[UILabel alloc] init];
    [self.backGroundSmallView addSubview:self.dateClickLabel];
    self.titleLineView = [[UIView alloc] init];
    [self.backGroundSmallView addSubview:self.titleLineView];
    self.kgLineView = [[UIView alloc] init];
    [self.backGroundSmallView addSubview:self.kgLineView];
    self.dateLineView = [[UIView alloc] init];
    [self.backGroundSmallView addSubview:self.dateLineView];
}

- (void)layoutSubviews{
    [super layoutSubviews];
    
    __weak typeof (self.backGroundSmallView) weakSelf = self.backGroundSmallView;

    [self.backGroundSmallView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.top.mas_equalTo(0);
        make.width.mas_equalTo(WIDTHVIEW);
        make.height.mas_equalTo(HEIGHTVIEW);
    }];
    self.backGroundSmallView.backgroundColor = [UIColor blackColor];
    self.backGroundSmallView.alpha = 0.8;
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.centerY.mas_equalTo(weakSelf.mas_centerY).with.offset(-80);
        make.size.mas_equalTo(CGSizeMake(80, 20));
    }];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.text = @"录入体重";
    self.titleLabel.textAlignment = YES;
    
    [self.titleLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.mas_centerX);
        make.centerY.mas_equalTo(weakSelf.mas_centerY).with.offset(-65);
        make.size.mas_equalTo(CGSizeMake(70, 2));
    }];
    self.titleLineView.backgroundColor = [UIColor lightGrayColor];
    
    [self.xButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakSelf.mas_centerX).with.offset(100);
        make.centerY.mas_equalTo(weakSelf.mas_centerY).with.offset(-80);
        make.size.mas_equalTo(CGSizeMake(30, 30));
    }];
    [self.xButton setImage:[UIImage imageNamed:@"quickInput_cancel@2x.png"] forState:UIControlStateNormal];
    
    [self.textFieldNumber mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_offset(UIEdgeInsetsMake(45, 10, 105, 30));
        make.center.mas_equalTo(weakSelf);
    }];
    self.textFieldNumber.textColor = COLORYELLO;
    self.textFieldNumber.font = [UIFont systemFontOfSize:40];
    self.textFieldNumber.textAlignment = YES;
    
    __weak typeof (self.textFieldNumber) weakTextFieldNumber = self.textFieldNumber;
    [self.kgLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakTextFieldNumber.mas_centerX).with.offset(110);
        make.centerY.mas_equalTo(weakTextFieldNumber.mas_centerY).with.offset(10);
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];
    self.kgLabel.textColor = [UIColor whiteColor];
    self.kgLabel.text = @"kg";
    
    [self.kgLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(weakTextFieldNumber.mas_centerX).with.offset(10);
        make.centerY.mas_equalTo(weakTextFieldNumber.mas_centerY).with.offset(25);
        make.size.mas_equalTo(CGSizeMake(WIDTHVIEW-30, 1));
    }];
    self.kgLineView.backgroundColor = [UIColor lightGrayColor];
    
    [self.dateLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(10);
        make.top.mas_equalTo(105);
        make.width.mas_equalTo(40);
        make.height.mas_equalTo(20);
    }];
    self.dateLabel.textColor = [UIColor grayColor];
    self.dateLabel.text = @"日期";
    
    [self.dateClickLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(50);
        make.top.mas_equalTo(100);
        make.width.mas_equalTo(WIDTHVIEW-40);
        make.height.mas_equalTo(30);
    }];
    self.dateClickLabel.textAlignment = YES;
    self.dateClickLabel.textColor = [UIColor whiteColor];
    
    [self.dateLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(130);
        make.width.mas_equalTo(WIDTHVIEW-30);
        make.height.mas_equalTo(1);
    }];
    self.dateLineView.backgroundColor = [UIColor lightGrayColor];
    
    [self.saveButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(HEIGHTVIEW-45);
        make.width.mas_equalTo(WIDTHVIEW-30);
        make.height.mas_equalTo(30);
    }];
    [self.saveButton setTitle:@"保存" forState:UIControlStateNormal];
    [self.saveButton setTitleColor:COLORYELLO forState:UIControlStateNormal];
    self.saveButton.layer.borderWidth = 1;
    self.saveButton.layer.cornerRadius = 5;
    self.saveButton.layer.masksToBounds = YES;
    self.saveButton.layer.borderColor = COLORYELLO.CGColor;
    
}


@end
